//
//  GCMHostInfoViewController.m
//  GeeCityManager
//
//  Created by 聚城科技 on 16/3/16.
//  Copyright © 2016年 聚城科技. All rights reserved.
//

#import "GCMHostInfoViewController.h"

@interface GCMHostInfoViewController ()

@end

@implementation GCMHostInfoViewController{
    
    NSMutableArray *_dataSource;
    UITableView *_tableV;
}
-(void)viewWillAppear:(BOOL)animated{
    
    self.navigationController.navigationBarHidden = NO;
    [self downLoadData];
}

- (void)viewDidLoad {
    [super viewDidLoad];
    [self initData];
    [self downLoadData];
    
    
    
}


-(void)downLoadData{
    
    [GCMHostSearchHttpRequst postDataWithcourtId:self.areaID WithbuildingId:self.buildID WithunitId:self.entranceID WithunitId:self.roomID Success:^(id obj, NSError *err) {
        _dataSource  = obj;
        NSLog(@"详细信息%@",_dataSource);
        NSLog(@"obj详细信息%@",obj);
        [self createUI];
    }];
}
-(void)createUI{

    self.view.backgroundColor = [UIColor colorWithRed:0.93 green:0.93 blue:0.93 alpha:1.00];
    UIView *view = [[UIView alloc]initWithFrame:CGRectMake(10, 74, SCREEN_WIDTH  - 20, 150)];
    view.backgroundColor = [UIColor whiteColor];
    view.layer.borderColor = [[UIColor redColor] CGColor];
    view.layer.borderWidth  = 1;
    view.layer.cornerRadius = 10;
    [self.view addSubview:view];
    UILabel *label1  = [[UILabel alloc]initWithFrame:CGRectMake(10, 50, view.bounds.size.width - 20, 1)];
    label1.layer.borderWidth = 1;
    label1.layer.borderColor = [[UIColor blackColor] CGColor];
    [view addSubview:label1];
    UILabel *label2  = [[UILabel alloc]initWithFrame:CGRectMake(10, 100, view.bounds.size.width - 20, 1)];
    label2.layer.borderWidth = 1;
    label2.layer.borderColor = [[UIColor blackColor] CGColor];
    [view addSubview:label2];
    
    UILabel *lab1  = [[UILabel alloc]initWithFrame:CGRectMake(10, 5, view.bounds.size.width - 20, 40)];
    lab1.text = [NSString stringWithFormat:@"房间 ： %@-%@-%@单元-%@",self.areaName,self.buildName,self.entranceName,self.roomID];
    lab1.textColor = [UIColor lightGrayColor];
    [view addSubview:lab1];
    
    UILabel *lab2  = [[UILabel alloc]initWithFrame:CGRectMake(10, 55, view.bounds.size.width - 20, 40)];
    lab2.text = [NSString stringWithFormat:@"住户 ： %@",[[_dataSource valueForKey:@"data"] valueForKey:@"name"]];
    lab2.textColor = [UIColor lightGrayColor];
    [view addSubview:lab2];
    
    UILabel *lab3  = [[UILabel alloc]initWithFrame:CGRectMake(10, 105, view.bounds.size.width - 20, 40)];
    lab3.text = [NSString stringWithFormat:@"联系电话 ： %@",[[_dataSource valueForKey:@"data"] valueForKey:@"tel"]];
    lab3.textColor = [UIColor lightGrayColor];
        [view addSubview:lab3];
    UIButton *telBtn = [[UIButton alloc]initWithFrame:CGRectMake(view.bounds.size.width - 40, 110, 30, 30)];
    telBtn.backgroundColor = [UIColor colorWithRed:0.24 green:0.43 blue:0.63 alpha:1];
    [telBtn setBackgroundImage:[UIImage imageNamed:@"common_btn_phone"] forState:UIControlStateNormal];
    [telBtn addTarget:self action:@selector(onTelBtnClick) forControlEvents:UIControlEventTouchUpInside];
    [view addSubview:telBtn];
    

}

-(void)onTelBtnClick{
    
    //    调用手机拨号
    NSString *phone=  [[_dataSource valueForKey:@"data"] valueForKey:@"tel"];
    //NSString *phone= @"18454262099";
    NSMutableString *str=[[NSMutableString alloc] initWithFormat:@"telprompt://%@",phone];
    [[UIApplication sharedApplication] openURL:[NSURL URLWithString:str]];
}
-(void)initData{
    
    _dataSource = [[NSMutableArray alloc]init];
    
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
 #pragma mark - Navigation
 
 // In a storyboard-based application, you will often want to do a little preparation before navigation
 - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
 // Get the new view controller using [segue destinationViewController].
 // Pass the selected object to the new view controller.
 }
 */

@end
